'use strict';

// 用户参数
const userParams = {
  name: { type: 'string', required: true, description: '姓名' },
  age: { type: 'number', required: true, description: '年龄' },
  sex: { type: 'number', required: true, enum: [ 0, 1 ], description: '性别 0-女 1-男' },
  birth: { type: 'string', required: true, description: '生日' },
  addr: { type: 'string', required: true, description: '地址' },
};

// id 参数
const idParams = {
  id: { type: 'number', required: true, description: 'id' },
};

const userItem = {
  id: { type: 'number', description: 'id' },
  name: { type: 'string', description: '姓名' },
  age: { type: 'number', description: '年龄' },
  sex: { type: 'number', enum: [ 0, 1 ], description: '性别 0-女 1-男' },
  birth: { type: 'string', description: '生日' },
  addr: { type: 'string', description: '地址' },
};

const codeRes = {
  code: { type: 'number', description: 'code', example: 20000 },
};

const totalRes = {
  count: { type: 'number', description: '总条数' },
};

const userListRes = {
  ...codeRes,
  ...totalRes,
  list: { type: 'array', itemType: 'userItem' },
};

const orgItem = {
  orgId: { type: 'string', description: '机构id' },
  orgName: { type: 'string', description: '机构名称' },
};

const orgListRes = {
  ...codeRes,
  list: { type: 'array', itemType: 'orgItem' },
};

const industryItem = {
  value: { type: 'string', description: '行业code' },
  label: { type: 'string', description: '行业名称' },
};
const industryListRes = {
  ...codeRes,
  data: { type: 'array', itemType: 'industryItem' },
};

const receiverItem = {
  receiverId: { type: 'string', description: '渠道id' },
  receiverName: { type: 'string', description: '渠道名称' },
};
const receiverListRes = {
  ...codeRes,
  data: { type: 'array', itemType: 'receiverItem' },
};

const mediaItem = {
  mediaId: { type: 'number', description: '媒体ID' },
  mediaName: { type: 'string', description: '媒体名称' },
  mediaState: { type: 'string', description: '媒体状态：NORMAL-正常，BANNED-停用' },
  mediaType: { type: 'string', description: '媒体类型：ANDROID, IOS, WEB, MINAPP' },
  appName: { type: 'string', description: '应用名称' },
  appPackage: { type: 'string', description: '应用包名' },
  appStoreUrl: { type: 'string', description: '应用商店地址' },
  domain: { type: 'string', description: '域名' },
  miniappId: { type: 'string', description: '小程序id' },
  miniappName: { type: 'string', description: '小程序名称' },
  orgId: { type: 'string', description: '媒体机构id' },
  industryCode: { type: 'string', description: '媒体行业code' },
  orgName: { type: 'string', description: '媒体名称' },
  industryName: { type: 'string', description: '媒体行业名称' },
  receivers: { type: 'array', itemType: 'receiverInfo', description: '关联渠道列表' },
};

const mediaListRes = {
  ...codeRes,
  ...totalRes,
  data: { type: 'array', itemType: 'mediaItem' },
};

const mediaDetailRes = {
  ...codeRes,
  data: { type: 'mediaItem' },
};

const createMediaParams = {
  mediaName: { type: 'string', required: true, description: '媒体名称' },
  orgId: { type: 'string', required: true, description: '媒体所属机构' },
  industryCode: { type: 'string', required: true, description: '媒体行业' },
  mediaType: { type: 'string', required: true, description: '媒体类型: ANDROID, IOS, WEB, MINAPP' },
  appName: { type: 'string', description: '应用名称' },
  appPackage: { type: 'string', description: '应用包名' },
  appStoreUrl: { type: 'string', description: '应用商店地址' },
  domain: { type: 'string', description: '域名' },
  miniappId: { type: 'string', description: '小程序id' },
  miniappName: { type: 'string', description: '小程序名称' },
};

const updateMediaParams = {
  mediaId: { type: 'string', required: true, description: '媒体ID' },
  mediaName: { type: 'string', description: '媒体名称' },
  appName: { type: 'string', description: '应用名称' },
  appPackage: { type: 'string', description: '应用包名' },
  appStoreUrl: { type: 'string', description: '应用商店地址' },
  domain: { type: 'string', description: '域名' },
  miniappId: { type: 'string', description: '小程序id' },
  miniappName: { type: 'string', description: '小程序名称' },
  mediaState: { type: 'string', description: '媒体状态：NORMAL-正常，BANNED-停用' },
};

const receiverInfo = {
  receiverId: { type: 'string', required: true, description: '关联渠道ID' },
  outMediaId: { type: 'string', required: true, description: '对应平台的媒体id' },
};

const addReceiverParams = {
  mediaId: { type: 'string', required: true, description: '媒体ID' },
  ...receiverInfo,
};

const updateReceiverParams = {
  mediaId: { type: 'string', required: true, description: '媒体ID' },
  receiverList: { type: 'array', required: true, itemType: 'receiverInfo' },
};


module.exports = {
  loginParams: {
    username: { type: 'string', required: true, description: '账户名' },
    password: { type: 'string', required: true, description: '密码' },
  },
  createUserParams: userParams,
  updateUserParams: {
    ...idParams,
    ...userParams,
  },
  deleteUserParams: idParams,
  userItem,
  userListRes,
  orgItem,
  orgListRes,
  industryItem,
  industryListRes,
  mediaItem,
  mediaListRes,
  mediaDetailRes,
  createMediaParams,
  updateMediaParams,
  receiverItem,
  receiverListRes,
  addReceiverParams,
  receiverInfo,
  updateReceiverParams,
};
